#include <cstdio>
#include <cstring>
using namespace std;

const int len_of_quad = 32;
const int len_of_input = 1024 + 10;

char str[len_of_input];
int img[len_of_quad][len_of_quad];
int pixels;

void draw(int &p, int r, int c, int q) {
  char character = str[p++];
  if (character == 'p') {
    draw(p, r          , c + (q / 2), q / 2);
    draw(p, r          , c          , q / 2);
    draw(p, r + (q / 2), c          , q / 2);
    draw(p, r + (q / 2), c + (q / 2), q / 2);
  }
  else if (character == 'f') {
    for (int i = r; i < (r + q); i++) {
      for (int j = c; j < (c + q); j++) {
        if (img[i][j] == 0) {
          img[i][j] = 1;
          pixels++;
        }
      }
    }
  }
}

int main() {
  int kase = 0;
  scanf("%d", &kase);
  while (kase--) {
    memset(img, 0, sizeof(img));
    pixels = 0;
    for (int i = 0; i < 2; i++) {
      int pos = 0;
      scanf("%s", str);
      draw(pos, 0, 0, len_of_quad);
    }
    printf("There are %d black pixels.\n", pixels);
  }
  
  return 0;
}
